home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 401-425 / disk_419 / reqaztec / reqbase.h < prev    next >
C/C++ Source or Header  |  1992-05-06  |  16KB  |  415 lines

  1.  
  2. /* reqlibrary.h © 1988/1989 reserved by Colin Fox and Bruce Dawson */
  3.  
  4. #ifndef REQLIBRARY_H
  5. #define REQLIBRARY_H
  6.  
  7. #ifndef    EXEC_LIBRARIES_H
  8. #include <exec/libraries.h>
  9. #endif
  10.  
  11. #ifndef    LIBRARIES_DOS_H
  12. #include <libraries/dos.h>
  13. #endif
  14.  
  15. #ifndef    INTUITION_INTUITION_H
  16. #include <intuition/intuition.h>
  17. #endif
  18.  
  19. #define    REQVERSION    1
  20.  
  21.  
  22. #define    NUMPAIRS    10
  23.  
  24. struct GadgetBlock {
  25.     struct Gadget        Gadget;
  26.     struct Border        Border;
  27.     WORD                Pairs[NUMPAIRS];
  28.     struct IntuiText    Text;
  29. };
  30.  
  31. struct StringBlock {
  32.     struct Gadget        Gadget;
  33.     struct StringInfo    Info;
  34.     struct Border        Border;
  35.     WORD                Pairs[NUMPAIRS];
  36. };
  37.  
  38. struct PropBlock {
  39.     struct Gadget        Gadget;
  40.     struct PropInfo        Info;
  41.     struct Image        Image;
  42. };
  43.  
  44. struct ScrollBlock {
  45.     struct Gadget        ArrowUpLt;
  46.     struct Image        ImageUpLt;
  47.     struct Gadget        ArrowDnRt;
  48.     struct Image        ImageDnRt;
  49.     struct PropBlock    Prop;
  50. };
  51.  
  52. struct TwoImageGadget {
  53.     struct Gadget        Gadget;
  54.     struct Image        Image1;
  55.     struct Image        Image2;
  56. };
  57.  
  58. #define    ATTITUDEB    16
  59.  
  60. #define    HORIZSLIDER        (0L<<ATTITUDEB)    /*;which way the slider stands*/
  61. #define    VERTSLIDER        (1L<<ATTITUDEB)    /*;This is so that it bypasses all gadget flags.*/
  62.  
  63.  
  64.  
  65. /*;         This structure is use with the TextRequester function.*/
  66.  
  67. struct TRStructure {
  68.     char    *Text;            /* ;This is the message text, including printf() style formatting if desired.*/
  69.     char    *Controls;        /* ;This is the address of the parameter list, if printf() style formatting is used.*/
  70.     struct Window *Window;    /* ;This is an optional (zero if not used) pointer to a window on the screen you*/
  71.                             /* ;would like the requester to show up on.*/
  72.     char    *MiddleText;    /* ;If non-zero, this is the text for the gadget in the lower middle (returns 2).*/
  73.     char    *PositiveText;    /* ;If non-zero, this is the text for the gadget in the lower left hand corner (returns 1).*/
  74.     char    *NegativeText;    /* ;If non-zero, this is the text for the gadget in the lower right (returns 0).*/
  75.     char    *Title;            /* ;This is the title for the window.*/
  76.     WORD    KeyMask;        /* ;This is the qualifier mask for the keyboard shortcuts.*/
  77.                             /* ;Use $FFFF to allow any qualifiers (or none).*/
  78.                             /* ;Zero means that no keyboard shortcuts are allowed.*/
  79.     WORD    textcolor;        /* ;Color of the text.  Uses color 1 if no color specified. */
  80.     WORD    detailcolor;    /* ;Detail and block color, as in a NewWindow structure.  If */
  81.     WORD    blockcolor;        /* ;both are left zero, block pen will be set to 1. */
  82.     WORD    versionnumber;    /* ;Make SURE this is set to zero. */
  83.     LONG    rfu1;            /* ;Make SURE you leave these two zeroed also. */
  84.     LONG    rfu2;            /* ;Make SURE you leave these two zeroed also. */
  85. };
  86.  
  87. /* NOTE:
  88.  *
  89.  *        The  control  values  mentioned above are used if you choose to insert
  90.  *    printf  style directives in your strings and should contain the address of
  91.  *    a list of control parameters, usually on the stack.
  92.  */
  93.  
  94.  
  95. /*;         Remember,   if  you  don't  want  to  go  through  the  hassle  of    */
  96. /*; initializing a ExtendedColorRequester structure, you can always just call    */
  97. /*; ColorRequester  (as opposed to ExtendedColorRequester).  ColorRequester        */
  98. /*; just  takes  a  single  parameter, in D0, the color that should start out    */
  99. /*; being highlit.  It returns a single value, the color that was selected at    */
  100. /*; the end.
  101.  
  102. /*;         This structure is for use with the ExtendedColorRequester (_not_, */
  103. /*; the ColorRequester) function. */
  104.  
  105. struct ExtendedColorRequester {
  106.     LONG    defcolor;        /*;The color that is initially highlit. */
  107.     APTR    window;            /*;The window the 'requester' opens up in. */
  108.     LONG    rfu1;            /*;Who knows what these will be used for, */
  109.     LONG    rfu2;            /*;but I'm sure we'll think of something. */
  110.     LONG    rfu3;            /*;Until then, just keep these zeroed. */
  111.     LONG    rfu4;            /*;Okay? */
  112.     LONG    rfu5;
  113. };
  114.  
  115.  
  116. /*;         This structure is for use with the GetLong function.*/
  117.  
  118. #define    GLNODEFAULTB    0    /*;Set this bit in the flags if you don't want a default*/
  119.                             /*;value to show up in the get long string gadget.  For*/
  120.                             /*;some things this is much better than having a zero*/
  121.                             /*;show up.*/
  122.  
  123. #define    GLNODEFAULTM    (1<<GLNODEFAULTB)
  124.  
  125. struct GetLongStruct {
  126.     char    *titlebar;
  127.     LONG    defaultval;
  128.     LONG    minlimit;
  129.     LONG    maxlimit;
  130.     LONG    result;
  131.     struct Window    *window;
  132.     WORD    versionnumber;    /* ;Make SURE this is set to zero. */
  133.     LONG    flags;            /* Some, uh flags.  See above for bit definitions. */
  134.     LONG    rfu2;            /* ;Make SURE you leave these two zeroed also. */
  135. };
  136.  
  137. struct GetStringStruct {
  138.     char    *titlebar;
  139.     char    *stringbuffer;
  140.     struct    Window *window;
  141.     WORD    stringsize;        /* how many characters in the buffer */
  142.     WORD    visiblesize;        /* how many characters show on screen */
  143.     WORD    versionnumber;
  144.     LONG    flags;
  145.     LONG    rfu1;
  146.     LONG    rfu2;
  147.     LONG    rfu3;
  148. };
  149.  
  150.  
  151.  
  152. #define    REQ_DSIZE    130
  153. #define    REQ_FCHARS    30
  154. #define    WILDLENGTH    30
  155.  
  156. /*
  157.  *        These  are  the  bit  numbers  of various bits that you can set in the
  158.  *    Flags  field of the file requester structure.  The actual values that come
  159.  *    out of these bit numbers are defined in the set of includes below with the
  160.  *    same  names  but  with  an  M  (for  mask) ending instead of a B (for bit)
  161.  *    ending.
  162.  */
  163.  
  164. #define    FRQSHOWINFOB    0    /*;Set this in Flags if you want .info files to show.  They default to hidden.*/
  165. #define    FRQEXTSELECTB    1    /*;Set this in Flags if you want extended select.  Default is not.*/
  166. #define    FRQCACHINGB        2    /*;Set this in Flags if you want directory caching.  Default is not.*/
  167. #define    FRQGETFONTSB    3    /*;Set this in Flags if you want a font requester rather than a file requester.*/
  168. #define    FRQINFOGADGETB    4    /*;Set this in Flags if you want a hide-info files gadget.*/
  169. #define    FRQHIDEWILDSB    5    /*;Set this in Flags if you DON'T want 'show' and 'hide' string gadgets.*/
  170. #define    FRQABSOLUTEXYB    6    /*;Use absolute x,y positions rather than centering on mouse.*/
  171. #define    FRQCACHEPURGEB    7    /*;Purge the cache whenever the directory date stamp changes if this is set.*/
  172. #define    FRQNOHALFCACHEB    8    /*;Don't cache a directory unless it is completely read in when this is set.*/
  173. #define    FRQNOSORTB        9    /*;Set this in Flags if you DON'T want sorted directories.*/
  174. #define    FRQNODRAGB        10    /*;Set this in Flags if you DON'T want a drag bar and depth gadgets.*/
  175. #define    FRQSAVINGB        11    /*;Set this bit if you are selecting a file to save to.*/
  176. #define    FRQLOADINGB        12    /*;Set this bit if you are selecting a file(s) to load from.*/
  177.                             /*;These two bits (save and load) aren't currently used for*/
  178.                             /*;anything, but they may be in the future, so you should*/
  179.                             /*;remember to set them.  Also, these bits make it easier if*/
  180.                             /*;somebody wants to customize the file requester for their*/
  181.                             /*;machine.  They can make it behave differently for loading*/
  182.                             /*;vs saving.*/
  183. #define    FRQDIRONLYB        13    /*;Allow the user to select a directory, rather than a file.*/
  184.  
  185. /*
  186.  *        These  are the mask values that you can OR into the Flags field of the
  187.  *    file requester structure.
  188.  */
  189.  
  190. #define    FRQSHOWINFOM    (1<<FRQSHOWINFOB)
  191. #define    FRQEXTSELECTM    (1<<FRQEXTSELECTB)
  192. #define    FRQCACHINGM        (1<<FRQCACHINGB)
  193. #define    FRQGETFONTSM    (1<<FRQGETFONTSB)
  194. #define    FRQINFOGADGETM    (1<<FRQINFOGADGETB)
  195. #define    FRQHIDEWILDSM    (1<<FRQHIDEWILDSB)
  196. #define    FRQABSOLUTEXYM    (1<<FRQABSOLUTEXYB)
  197. #define    FRQCACHEPURGEM    (1<<FRQCACHEPURGEB)
  198. #define    FRQNOHALFCACHEM    (1<<FRQNOHALFCACHEB)
  199. #define    FRQNOSORTM        (1<<FRQNOSORTB)
  200. #define    FRQNODRAGM        (1<<FRQNODRAGB)
  201. #define    FRQSAVINGM        (1<<FRQSAVINGB)
  202. #define    FRQLOADINGM        (1<<FRQLOADINGB)
  203. #define    FRQDIRONLYM        (1<<FRQDIRONLYB)
  204.  
  205. struct ESStructure {
  206.     struct ESStructure    *NextFile;
  207.     WORD    NameLength;            /* Length of thefilename field, not including the terminating zero. */
  208.     WORD    Pad;
  209.     APTR    Node;                /* For internal use only. */
  210.     char    thefilename[1];        /* This is a variable size field. */
  211. };
  212.  
  213. struct FileReq {
  214.     UWORD    VersionNumber;                /* Make sure this is zeroed for now. */
  215.     char    *Title;                        /* Hailing text */
  216.     char    *Dir;                        /* Directory array (REQ_DSIZE+1) */
  217.     char    *File;                        /* Filename array (REQ_FCHARS+1) */
  218.     char    *PathName;                    /* Complete path name array (REQ_DSIZE+REQ_FCHARS+2) */
  219.     struct Window    *Window;            /* Window requesting or NULL */
  220.     UWORD    MaxExtendedSelect;            /* Zero implies a maximum of 65535, as long as FRQEXTSELECT is set.*/
  221.     UWORD    numlines;                    /* Number of lines in file window. */
  222.     UWORD    numcolumns;                    /* Number of columns in file window. */
  223.     UWORD    devcolumns;
  224.     ULONG    Flags;                        /* Various - umm - flags.  See above for more info. */
  225.     UWORD    dirnamescolor;            /* These five colors will all default */
  226.     UWORD    filenamescolor;            /* to color one if you don't specify */
  227.     UWORD    devicenamescolor;        /* a color (ie; if you specify color zero). */
  228.     UWORD    fontnamescolor;            /* If you want color zero to be used, specify */
  229.     UWORD    fontsizescolor;            /* color 32, or some other too large number */
  230.                                     /* which mods down to zero. */
  231.     UWORD    detailcolor;            /* If both of these colors are specified as */
  232.     UWORD    blockcolor;                /* zero then the block pen will be set to one. */
  233.     UWORD    gadgettextcolor;        /* The color for the text of the five boolean gadgets.  Defaults to 1. */
  234.     UWORD    textmessagecolor;        /* The color for the message at the screen top.  Defaults to 1. */
  235.     UWORD    stringnamecolor;        /* The color for the words Drawer, File, Hide and Show.  Defaults to 3. */
  236.     UWORD    stringgadgetcolor;        /* The color for the borders of the string gadgets.  Defaults to 3. */
  237.                                     /* Unfortunately it is not possible to specify */
  238.                                     /* the color of the actual text in an Intuition */
  239.                                     /* string gadget. */
  240.     UWORD    boxbordercolor;            /* The color for the boxes around the file and directory areas.  Defaults to 3. */
  241.     UWORD    gadgetboxcolor;            /* The color for the boxes around the five boolean gadgets.  Defaults to 3. */
  242.     UWORD    FRU_Stuff[18];                /* This area, which is reserved for */
  243.                                         /* future use, should all be zero. */
  244.     struct DateStamp    DirDateStamp;    /* A copy of the cached directories date stamp. */
  245.                                         /* There should never be any need to change this. */
  246.     UWORD    WindowLeftEdge;            /* These two fields are only used when the */
  247.     UWORD    WindowTopEdge;            /* FRQABSOLUTEXY flag is set.  They specify */
  248.                                     /* the location of the upper left hand */
  249.                                     /* corner of the window. */
  250.     UWORD    FontYSize;                /* These fields are used to return the selected */
  251.     UWORD    FontStyle;                /* font size and style, only applicable when the */
  252.                                     /* font bit is set. */
  253.  
  254.     /*If you set the extended select bit and the user extended selects, the list of filenames will start from here.*/
  255.     struct ESStructure *ExtendedSelect;
  256.  
  257.     char    Hide[WILDLENGTH+2];        /* The wildcards text. */
  258.     char    Show[WILDLENGTH+2];        /* More wildcards text. */
  259.     WORD    FileBufferPos;            /* Various fields taken from the various */
  260.     WORD    FileDispPos;            /* string gadgets so that the cursor */
  261.     WORD    DirBufferPos;            /* can be returned to the same position */
  262.     WORD    DirDispPos;                /* on subsequent calls. */
  263.     WORD    HideBufferPos;
  264.     WORD    HideDispPos;
  265.     WORD    ShowBufferPos;
  266.     WORD    ShowDispPos;
  267.  
  268. /**;        The  following  fields are PRIVATE!  Don't go messing with them or
  269.  **;    wierd  things may/will happen.  If this isn't enough of a warning, go read
  270.  **;    the one in intuition.h, that should scare you off.
  271.  **/
  272.  
  273.     APTR    Memory;                        /* Memory allocate for dir entries. */
  274.     APTR    Memory2;                    /* More memory, used for hidden files. */
  275.     APTR    Lock;
  276.     char    PrivateDirBuffer[REQ_DSIZE+2];    /* Used for keeping a record of which */
  277.                                         /* directory we have file names for. */
  278.     struct FileInfoBlock    *FileInfoBlock;
  279.     WORD    NumEntries;
  280.     WORD    NumHiddenEntries;
  281.     WORD    filestartnumber;
  282.     WORD    devicestartnumber;
  283. };
  284.  
  285.  
  286. /*        This is used with the RealTimeScroll function. */
  287.  
  288. struct ScrollStruct {
  289.     ULONG    TopEntryNumber;            /*;This is the ordinal number of the first*/
  290.                                     /*;displayed entry.*/
  291.     ULONG    NumEntries;                /*;This is the total number of entries in*/
  292.                                     /*;the list.*/
  293.     UWORD    LineSpacing;            /*;This is how many pixels high each entry is.*/
  294.     ULONG    NumLines;                /*;This is how many entries can be displayed simultaneously.*/
  295.     struct Gadget    *PropGadget;    /*;This is a pointer to the prop gadget being monitored.*/
  296.  
  297.     void    (*RedrawAll)();            /*;This routine is used to redraw all of the*/
  298.                                     /*;entries when the user moves far enough*/
  299.                                     /*;that scrolling will take too long.*/
  300.  
  301.     void    (*ReadMore)();            /*;An optional routine that is called when*/
  302.                                     /*;the scroll routine is waiting for movement.*/
  303.                                     /*;This allows reading of new data while real*/
  304.                                     /*;time scrolling.*/
  305.     void    (*ScrollAndDraw)();        /*;This routine is called when the data needs*/
  306.                                     /*;to be scrolled and updated.  This routine is*/
  307.                                     /*;passed four long parameters (on the stack and*/
  308.                                     /*;in D0-D3) which are, respectively:*/
  309.                                     /*;D0 - entry number of first line to be drawn.*/
  310.                                     /*;D1 - pixel offset to draw first line at.*/
  311.                                     /*;D2 - amount to scroll before doing any drawing.*/
  312.                                     /*;D3 - number of lines of data to draw.*/
  313.     WORD    versionnumber;            /*;Make SURE this is set to zero. */
  314.     LONG    rfu1;                    /*;Make SURE you leave these two zeroed also. */
  315.     LONG    rfu2;                    /*;Make SURE you leave these two zeroed also. */
  316. };
  317.  
  318.  
  319. struct chipstuff {
  320.     char    ArrowUp[20];        /* 16 pixels wide, 10 pixels high. */
  321.     char    ArrowDown[20];        /* 16 pixels wide, 10 pixels high. */
  322.     char    ArrowLeft[18];        /* 16 pixels wide, 9 pixels high. */
  323.     char    ArrowRight[18];        /* 16 pixels wide, 9 pixels high. */
  324.     char    Letter_R[20];        /* 16 pixels wide, 10 pixels high. */
  325.     char    Letter_G[20];        /* 16 pixels wide, 10 pixels high. */
  326.     char    Letter_B[20];        /* 16 pixels wide, 10 pixels high. */
  327.     char    Letter_H[20];        /* 16 pixels wide, 10 pixels high. */
  328.     char    Letter_S[20];        /* 16 pixels wide, 10 pixels high. */
  329.     char    Letter_V[20];        /* 16 pixels wide, 10 pixels high. */
  330. };
  331.  
  332. struct ReqLib {
  333.     struct Library RLib;
  334.     struct AbsExecBase        *SysLib;
  335.     struct DosBase            *DosLib;
  336.     struct IntuitionBase    *IntuiLib;
  337.     struct GfxBase            *GfxLib;
  338.     APTR                    SegList;
  339.     struct chipstuff        *Images;
  340.     BYTE                    Flags;
  341.     BYTE                    Pad;
  342.     char                    *ConsoleDev;    /* Not really a char*, but it should work */
  343.     struct    IOStdReq        *ConsoleHandle;
  344. };
  345.  
  346.  
  347. /* Prototypes */
  348.  
  349. void Center(struct NewWindow *,int,int);
  350.  
  351. short SetSize(long,long);
  352. long SetLocation(long,long,long);
  353. long ReadLocation(long,long,short);
  354.  
  355. void Format(char *,char *,...);                        /* No pragmas */
  356.  
  357. void SimpleRequest(char *title,char *fmt,...);        /* No pragmas */
  358. short TwoGadRequest(char *title,char *fmt,...);        /* No pragmas */
  359.  
  360. short FileRequester(struct FileReq *);
  361. void PurgeFiles(struct FileReq *);
  362.  
  363. short ColorRequester(long);
  364. short ExtendedColorRequester(struct ExtendedColorRequester *);
  365.  
  366. void MakeGadget(struct GadgetBlock *,char *,ULONG,ULONG);
  367. void MakeString(struct StringBlock *,char *,char *,ULONG,ULONG,long,long);
  368. void MakeProp(struct PropBlock *,ULONG,ULONG,ULONG);
  369. void MakeButton(struct TwoImageGadget *,struct Image *,struct Image *,long,long,long);
  370.  
  371. void MakeScrollBar(struct ScrollBlock *,long,long,long,long);
  372.  
  373. void LinkGadget(struct GadgetBlock *,char *,struct NewWindow *,long,long);
  374. void LinkStringGadget(struct StringBlock *,char *,char *,struct NewWindow *,long,long,long,long);    /* No pragmas */
  375. void LinkPropGadget(struct PropBlock *,struct NewWindow *,long,long,long,long,long);                /* No pragmas */
  376.  
  377. void DrawBox(struct RastPort *,long,long,long,long);
  378.  
  379. /* GetFontHeightAndWidth()            No access from C language (two results) */
  380.  
  381. void RealTimeScroll(struct ScrollStruct *);
  382.  
  383. short TextRequest(struct TRStructure *);
  384.  
  385. BOOL GetString(char *,char *,struct Window *,long,long);
  386. BOOL GetLong(struct GetLongStruct *);
  387.  
  388. char RawKeyToAscii(long,long,APTR);
  389.  
  390. BOOL NewGetString(struct GetStringStruct *);
  391.  
  392. /************************************************************************
  393.  *    Check if we should do the pragmas...                                *
  394.  ************************************************************************/
  395.  
  396. #ifndef    NO_PRAGMAS
  397.  
  398.     /* for Lattice */
  399.     #ifdef LATTICE
  400.         #ifndef PROTO_REQ_H
  401.             #include <Proto/req.h>
  402.         #endif
  403.     #endif
  404.  
  405.     /* for Manx 5.0 */
  406.     #ifdef AZTEC_C
  407.         #ifndef    REQ_PRAGMAS_H
  408.             #include <req_pragmas.h>
  409.         #endif
  410.     #endif
  411.  
  412. #endif
  413.  
  414. #endif
  415.